package com.swan;

import org.springframework.messaging.simp.SimpMessagingTemplate;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/message")
public class TriggerController {
    private final SimpMessagingTemplate messagingTemplate;

    public TriggerController(WebSocketController controller, SimpMessagingTemplate messagingTemplate) {
        this.messagingTemplate = messagingTemplate;
    }

    @GetMapping("/send")
    public String set(@RequestParam("message") String message){
        messagingTemplate.convertAndSendToUser("swan","/queue/message",message);
        return message;
    }
}
